]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Consolidate ConsoleKit and Systemd code
authorGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 17 Aug 2012 12:18:53 +0000 (14:18 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 17 Aug 2012 17:10:27 +0000 (19:10 +0200)
In preparation for accessing it in the screenshield, factor out
common code for ConsoleKit and Systemd.
Also, clean up ConsoleKit manager, as the daemon is required in
a non systemd installation. In particular:
- We allow it to be autostarted at session startup (or really,
  we expect it to be already there, started by GDM during session
  opening).
- We no longer silently assume that the session is active if
  it can't start.

https://bugzilla.gnome.org/show_bug.cgi?id=682096

js/Makefile.am
js/gdm/consoleKit.js [deleted file]
js/gdm/powerMenu.js
js/gdm/systemd.js [deleted file]
js/misc/consoleKit.js [new file with mode: 0644]
js/misc/systemd.js [new file with mode: 0644]
js/ui/automountManager.js

index 91dc84ca73dc09dcbedceb12f121a2229f5cd30d..37c4a927883a32f54fbd67ea1672de0db287f524 100644 (file)
@@ -17,14 +17,13 @@ jsdir = $(pkgdatadir)/js
 
 nobase_dist_js_DATA =  \
        gdm/batch.js            \
-       gdm/consoleKit.js       \
        gdm/fingerprint.js      \
        gdm/loginDialog.js      \
        gdm/powerMenu.js        \
-       gdm/systemd.js          \
        gdm/util.js             \
        extensionPrefs/main.js  \
        misc/config.js          \
+       misc/consoleKit.js      \
        misc/extensionUtils.js  \
        misc/fileUtils.js       \
        misc/gnomeSession.js    \
@@ -32,6 +31,7 @@ nobase_dist_js_DATA =         \
        misc/jsParse.js         \
        misc/modemManager.js    \
        misc/params.js          \
+       misc/systemd.js         \
        misc/util.js            \
        perf/core.js            \
        ui/altTab.js            \
diff --git a/js/gdm/consoleKit.js b/js/gdm/consoleKit.js
deleted file mode 100644 (file)
index 6445a8c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-
-const Gio = imports.gi.Gio;
-
-const ConsoleKitManagerIface = <interface name='org.freedesktop.ConsoleKit.Manager'>
-<method name='CanRestart'>
-    <arg type='b' direction='out'/>
-</method>
-<method name='CanStop'>
-    <arg type='b' direction='out'/>
-</method>
-<method name='Restart' />
-<method name='Stop' />
-</interface>;
-
-const ConsoleKitProxy = Gio.DBusProxy.makeProxyWrapper(ConsoleKitManagerIface);
-
-function ConsoleKitManager() {
-    return new ConsoleKitProxy(Gio.DBus.system,
-                               'org.freedesktop.ConsoleKit',
-                               '/org/freedesktop/ConsoleKit/Manager');
-};
index 613a89607cb98673175965e76d35c185998dcd92..e06c7a26809e4b078fc470d6e2cc835d5166f714 100644 (file)
@@ -21,8 +21,8 @@
 const Lang = imports.lang;
 const UPowerGlib = imports.gi.UPowerGlib;
 
-const ConsoleKit = imports.gdm.consoleKit;
-const Systemd = imports.gdm.systemd;
+const ConsoleKit = imports.misc.consoleKit;
+const Systemd = imports.misc.systemd;
 
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
diff --git a/js/gdm/systemd.js b/js/gdm/systemd.js
deleted file mode 100644 (file)
index 8dd73ab..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-
-const GLib = imports.gi.GLib;
-const Gio = imports.gi.Gio;
-
-const SystemdLoginManagerIface = <interface name='org.freedesktop.login1.Manager'>
-<method name='PowerOff'>
-    <arg type='b' direction='in'/>
-</method>
-<method name='Reboot'>
-    <arg type='b' direction='in'/>
-</method>
-<method name='CanPowerOff'>
-    <arg type='s' direction='out'/>
-</method>
-<method name='CanReboot'>
-    <arg type='s' direction='out'/>
-</method>
-</interface>;
-
-const SystemdLoginManagerProxy = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
-
-function SystemdLoginManager() {
-    return new SystemdLoginManagerProxy(Gio.DBus.system,
-                                        'org.freedesktop.login1',
-                                        '/org/freedesktop/login1');
-};
-
-function haveSystemd() {
-    return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
-}
diff --git a/js/misc/consoleKit.js b/js/misc/consoleKit.js
new file mode 100644 (file)
index 0000000..96afd5a
--- /dev/null
@@ -0,0 +1,55 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const Gio = imports.gi.Gio;
+
+const ConsoleKitManagerIface = <interface name='org.freedesktop.ConsoleKit.Manager'>
+<method name='CanRestart'>
+    <arg type='b' direction='out'/>
+</method>
+<method name='CanStop'>
+    <arg type='b' direction='out'/>
+</method>
+<method name='Restart' />
+<method name='Stop' />
+<method name='GetCurrentSession'>
+    <arg type='o' direction='out' />
+</method>
+</interface>;
+
+const ConsoleKitSessionIface = <interface name='org.freedesktop.ConsoleKit.Session'>
+<method name='IsActive'>
+    <arg type='b' direction='out' />
+</method>
+<signal name='ActiveChanged'>
+    <arg type='b' direction='out' />
+</signal>
+<signal name='Lock' />
+<signal name='Unlock' />
+</interface>;
+
+const ConsoleKitSessionProxy = Gio.DBusProxy.makeProxyWrapper(ConsoleKitSessionIface);
+
+const ConsoleKitManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(ConsoleKitManagerIface);
+
+function ConsoleKitManager() {
+    var self = new Gio.DBusProxy({ g_connection: Gio.DBus.system,
+                                  g_interface_name: ConsoleKitManagerInfo.name,
+                                  g_interface_info: ConsoleKitManagerInfo,
+                                  g_name: 'org.freedesktop.ConsoleKit',
+                                  g_object_path: '/org/freedesktop/ConsoleKit/Manager',
+                                   g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
+    self.init(null);
+
+    self.GetCurrentSessionRemote(function([session]) {
+        self.ckSession = new ConsoleKitSessionProxy(Gio.DBus.system, 'org.freedesktop.ConsoleKit', session);
+
+        self.ckSession.connectSignal('ActiveChanged', function(object, senderName, [isActive]) {
+            self.sessionActive = isActive;
+        });
+        self.ckSession.IsActiveRemote(function([isActive]) {
+            self.sessionActive = isActive;
+        });
+    });
+
+    return self;
+}
diff --git a/js/misc/systemd.js b/js/misc/systemd.js
new file mode 100644 (file)
index 0000000..39ef129
--- /dev/null
@@ -0,0 +1,44 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
+
+const SystemdLoginManagerIface = <interface name='org.freedesktop.login1.Manager'>
+<method name='PowerOff'>
+    <arg type='b' direction='in'/>
+</method>
+<method name='Reboot'>
+    <arg type='b' direction='in'/>
+</method>
+<method name='CanPowerOff'>
+    <arg type='s' direction='out'/>
+</method>
+<method name='CanReboot'>
+    <arg type='s' direction='out'/>
+</method>
+</interface>;
+
+const SystemdLoginSessionIface = <interface name='org.freedesktop.login1.Session'>
+<signal name='Lock' />
+<signal name='Unlock' />
+</interface>;
+
+const SystemdLoginManagerProxy = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
+
+const SystemdLoginSessionProxy = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
+
+function SystemdLoginManager() {
+    return new SystemdLoginManagerProxy(Gio.DBus.system,
+                                        'org.freedesktop.login1',
+                                        '/org/freedesktop/login1');
+};
+
+function SystemdLoginSession(id) {
+    return new SystemdLoginSessionProxy(Gio.DBus.system,
+                                        'org.freedesktop.login1',
+                                        '/org/freedesktop/login1/session/' + id);
+}
+
+function haveSystemd() {
+    return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
+}
index 69a94cb8265a5f119c2093b17ca91b84c9c5456f..19f2aca667abcb147c2e0656c12b99406d1486ca 100644 (file)
@@ -5,11 +5,13 @@ const Mainloop = imports.mainloop;
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Params = imports.misc.params;
-
 const Shell = imports.gi.Shell;
+
+const ConsoleKit = imports.misc.consoleKit;
+const GnomeSession = imports.misc.gnomeSession;
 const Main = imports.ui.main;
 const ShellMountOperation = imports.ui.shellMountOperation;
-const GnomeSession = imports.misc.gnomeSession;
+const Systemd = imports.misc.systemd;
 
 const GNOME_SESSION_AUTOMOUNT_INHIBIT = 16;
 
@@ -19,62 +21,6 @@ const SETTING_ENABLE_AUTOMOUNT = 'automount';
 
 const AUTORUN_EXPIRE_TIMEOUT_SECS = 10;
 
-const ConsoleKitSessionIface = <interface name="org.freedesktop.ConsoleKit.Session">
-<method name="IsActive">
-    <arg type="b" direction="out" />
-</method>
-<signal name="ActiveChanged">
-    <arg type="b" direction="out" />
-</signal>
-</interface>;
-
-const ConsoleKitSessionProxy = Gio.DBusProxy.makeProxyWrapper(ConsoleKitSessionIface);
-
-const ConsoleKitManagerIface = <interface name="org.freedesktop.ConsoleKit.Manager">
-<method name="GetCurrentSession">
-    <arg type="o" direction="out" />
-</method>
-</interface>;
-
-const ConsoleKitManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(ConsoleKitManagerIface);
-
-function ConsoleKitManager() {
-    var self = new Gio.DBusProxy({ g_connection: Gio.DBus.system,
-                                  g_interface_name: ConsoleKitManagerInfo.name,
-                                  g_interface_info: ConsoleKitManagerInfo,
-                                  g_name: 'org.freedesktop.ConsoleKit',
-                                  g_object_path: '/org/freedesktop/ConsoleKit/Manager',
-                                   g_flags: (Gio.DBusProxyFlags.DO_NOT_AUTO_START |
-                                             Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
-
-    self._updateSessionActive = function() {
-        if (self.g_name_owner) {
-            self.GetCurrentSessionRemote(function([session]) {
-                self._ckSession = new ConsoleKitSessionProxy(Gio.DBus.system, 'org.freedesktop.ConsoleKit', session);
-
-                self._ckSession.connectSignal('ActiveChanged', function(object, senderName, [isActive]) {
-                    self.sessionActive = isActive;
-                });
-                self._ckSession.IsActiveRemote(function([isActive]) {
-                    self.sessionActive = isActive;
-                });
-            });
-        } else {
-            self.sessionActive = true;
-        }
-    };
-    self.connect('notify::g-name-owner',
-                 Lang.bind(self, self._updateSessionActive));
-
-    self._updateSessionActive();
-    self.init(null);
-    return self;
-}
-
-function haveSystemd() {
-    return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
-}
-
 const AutomountManager = new Lang.Class({
     Name: 'AutomountManager',
 
@@ -88,8 +34,8 @@ const AutomountManager = new Lang.Class({
                                     Lang.bind(this, this._InhibitorsChanged));
         this._inhibited = false;
 
-        if (!haveSystemd())
-            this.ckListener = new ConsoleKitManager();
+        if (!Systemd.haveSystemd())
+            this.ckListener = new ConsoleKit.ConsoleKitManager();
 
         Main.screenShield.connect('lock-status-changed', Lang.bind(this, this._lockStatusChanged));
 
@@ -151,7 +97,7 @@ const AutomountManager = new Lang.Class({
         // right mechanism: either systemd if available or ConsoleKit
         // as fallback.
 
-        if (haveSystemd())
+        if (Systemd.haveSystemd())
             return Shell.session_is_active_for_systemd();
 
         return this.ckListener.sessionActive;